package com.xiaoai.java8_stream;

import org.junit.Test;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author
 * @Date 2021-09-17 22:42
 */
public class MTest {

    @Test
    public void test1(){

        List<String> strings = Arrays.asList("abc", "", "bc", "efg", "abcd", "", "jkl",null);

//        List<String> filter = strings.stream().filter(str -> str.contains("f")).collect(Collectors.toList());
//        System.out.println(filter);

        List<String> filter1 = strings.stream().filter(Objects::nonNull).collect(Collectors.toList());
        System.out.println(filter1);

        List<String> filter2 = strings.stream().filter(str -> {
            return Testt.drg(str);
        }).collect(Collectors.toList());
        System.out.println(filter2);



    }

    @Test
    public void testM(){
        HashMap<Object, Object> map = new HashMap<>();
        map.put("xiao1","ai1");
        map.put("xiao2","ai2");
        map.put("xiao3","ai3");
        map.forEach((k,v) -> System.out.println(k+"="+v));

        List<String> list = new ArrayList<>();
        list.add("xiaoai1");
        list.add("xiaoai2");
        list.add("xiaoai3");

        list.forEach((str) -> {
            System.out.println(str);
        });

    }
}
